

**********************************************************************
** Euro Units--Beyond Coal
********************************************************************
import excel "../Raw/EuroPlantEmission/2022-10-20-Europe_Beyond_Coal-European_Coal_Database.xlsx", sheet("Unit") firstrow clear cellrange(A2)
drop if missing(EBCplantID)
order EBCplantID EBCunitID Plantname Owner
sort Owner


replace Owner="Albioma SA" if Owner=="Albioma"
// Bulgarian Energy Holding (BEH) matched
replace Owner="CEZ AS" if Owner=="CEZ"
replace Owner="Electricite de France SA (EDF Group)" if Owner=="EDF"
// Elektroprivreda Srbije (EPS) matched
replace Owner="EnBW Energie Baden-Württemberg AG" if Owner=="EnBW"
replace Owner="Enea SA" if Owner=="Enea"
replace Owner="Enel SpA" if Owner=="Enel"
replace Owner="Energa SA" if Owner=="Energa"
replace Owner="Energeticky a prumyslovy holding a.s. (EPH)" if Owner=="EPH"
replace Owner="EVN AG" if Owner=="EVN"
replace Owner="Fortum Oyj" if Owner=="Fortum"
replace Owner="PGE SA (Polska Grupa Energetyczna SA)" if Owner=="PGE"
replace Owner="Polskie Górnictwo Naftowe i Gazownictwo SA (PGNiG)" if Owner=="PGNiG"
replace Owner="Public Power Corporation SA (PPC)" if Owner=="PPC"
replace Owner="ContourGlobal plc" if Owner=="ContourGlobal"
replace Owner="RWE AG" if Owner=="RWE"
replace Owner="Sev.en Energy Group" if Owner=="Sev.en Energy AG"
//Sokolovská Uhelná AS matched
replace Owner="STEAG GmbH" if Owner=="Steag"
replace Owner="TAURON Polska Energia S.A" if Owner=="Tauron"
replace Owner="ZE PAK SA Group (Zespół Elektrowni Pątnów Adamów Konin SA)" if Owner=="ZEPAK"
replace Owner="Elektrocieplownia Bedzin SA" if Owner=="EC Będzin SA"
// Vaskiluodon Voima Oy matched
replace Owner="Helen Ltd" if Owner=="Helen"
replace Owner="EFT Rudnik i Termoelektrana Stanari d.o.o" if Owner=="EFT"
replace Owner="Magyar Villamos Művek Zrt (MVM)" if Owner=="MVM"

gen announced_retirement_plans = year(Dateofretirementannouncement)
ren (Plantname Owner AnnouncedRetirementyear EBCunitID) (Plant  plant_company planned_retirement_year_earliest Unit)
keep Plant plant_company planned_retirement_year_earliest announced_retirement_plans EBCplantID Unit
duplicates drop


replace Unit = regexr(Unit, "^" + EBCplantID + "-?", "")
replace Unit = "Unit " + Unit


egen eu_id = group(Plant plant_company planned_retirement_year_earliest announced_retirement_plans EBCplantID Unit)

gen modified_plant = Plant
replace modified_plant = modified_plant + " power station" if strpos(modified_plant, "power station") == 0
replace modified_plant = subinstr(modified_plant, ".", "",.) 
replace modified_plant = subinstr(modified_plant, ",", "",.) 
replace modified_plant = strtrim(modified_plant)
replace modified_plant = strupper(modified_plant) 

drop if Plant == "Karvina power station" & Unit == "Unit 1" //Dropping one weird observation



save "../Intermediate/eu_beyond_coal_generator_data.dta", replace



